<template >
  <div class="bg">
    <div class="share-content">
      <div class="top-content">
        <p class="text text-name">我是{{this.$route.query.nickname}}</p>
        <p class="text text-dy">我为首象代言</p>
        <img src="" id="qrcodeimg" alt="">
      </div>
      <div class="bottom-content">
        <img src="../../../assets/personal/images/sxgx-pic.png" alt="">
        <p class="b-text"> 一款上线首月即拥有百万粉丝流量的商家免费引流微信公众平台</p>
        <p class="b-text"> 这是商家的引流增销平台，全方位锁定用户消费及转介绍 </p>
        <p class="b-text">这是用户的自由创业平台，全方位锁定资源并将资源变现</p>
      </div>
    </div>
    <!--<div class="backTo" onclick="javascript:history.back(-1);">返回</div>-->
  </div>
</template>
<style scoped>
  @import "../../../assets/personal/css/share_qrcode.css";
  .jinqian{
    margin-left: 6rem;
  }
  .bg{
    height: 100%;
  }
  .share-content{
    height: 100%;
    background: #2b2d40;
  }
</style>
<script>

  import QRCode from "qrcode"
  //import wx from 'weixin-js-sdk'
  export default {
    data(){
      return{
        urlid:'',
        nickname:''
      }
    },
    mounted(){
      this.urlid=this.$route.query.id;
      this.nickname=this.$route.query.nickname;
      this.qrcode();
      this.getwxconfig();
    },
    methods: {
      qrcode () {

        QRCode.toDataURL("http://"+window.location.host+"/wap/wx/login?fk=1-7-"+this.urlid+"-"+0)
          .then(url => {
            document.getElementById("qrcodeimg").src=url;
          })
          .catch(err => {
            console.error(err)
          })
      },
      getwxconfig(){
        var vm= this;
        console.log(vm);
        this.$http.get(this.APIURL_PREFIX+"/api/wxs/config?url="+escape(location.href.split('#')[0])).then((response) => {
          console.log(response.data);
          var appid = 'wx488ae3f57360b7ea';
          wx.config({
            debug: false,
            appId: appid,
            timestamp: response.data.data.timestamp,
            nonceStr: response.data.data.noncestr,
            signature: response.data.data.signature,
            jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone','scanQRCode']
          });
          wx.ready(function(){
            wx.onMenuShareTimeline({
              title: "我是"+vm.nickname+"，我为首象代言",
              link: "http://"+window.location.host+"/wap/wx/login?fk=1-7-"+vm.urlid+"-"+0,
              imgUrl:app.imgSrc,
              desc:" 首象共享，一款上线首月即拥有百万粉丝流量的商家免费引流微信公众平台",
              success: function () {
              },
              cancel: function () {
              }
            });
            wx.onMenuShareAppMessage({
              title: "我是"+vm.nickname+"，我为首象代言",
              link: "http://"+window.location.host+"/wap/wx/login?fk=1-7-"+vm.urlid+"-"+0,
              imgUrl:app.imgSrc,
              desc:" 首象共享，一款上线首月即拥有百万粉丝流量的商家免费引流微信公众平台",
              success: function () {
              },
              cancel: function () {
              }
            });
            wx.onMenuShareQQ({
              title: "我是"+vm.nickname+"，我为首象代言",
              link: "http://"+window.location.host+"/wap/wx/login?fk=1-7-"+vm.urlid+"-"+0,
              imgUrl:app.imgSrc,
              desc:" 首象共享，一款上线首月即拥有百万粉丝流量的商家免费引流微信公众平台",
              success: function () {
              },
              cancel: function () {
              }
            });
            wx.onMenuShareWeibo({
              title: "我是"+vm.nickname+"，我为首象代言",
              link: "http://"+window.location.host+"/wap/wx/login?fk=1-7-"+vm.urlid+"-"+0,
              imgUrl:app.imgSrc,
              desc:" 首象共享，一款上线首月即拥有百万粉丝流量的商家免费引流微信公众平台",
              success: function () {
              },
              cancel: function () {
              }
            });
            wx.onMenuShareQZone({
              title: "我是"+vm.nickname+"，我为首象代言",
              link: "http://"+window.location.host+"/wap/wx/login?fk=1-7-"+vm.urlid+"-"+0,
              imgUrl:app.imgSrc,
              desc:" 首象共享，一款上线首月即拥有百万粉丝流量的商家免费引流微信公众平台",
              success: function () {
              },
              cancel: function () {
              }
            });

          });
        }).catch(function(err){
          console.log(err)
        });

      }
    }

  }
</script>
